/*
 * @Author: szx
 * @Date: 2021-12-02 16:46:55
 * @LastEditTime: 2021-12-02 16:53:20
 * @Description:
 * @FilePath: \leetcode\100-199\153\153.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var findMin = function (nums) {
    const n = nums.length;
    let l = 0,
        r = n - 1;
    while (l < r) {
        const mid = Math.floor((l + r) / 2);
        if (nums[mid] < nums[r]) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    return nums[l];
};
console.log(findMin([3, 4, 5, 1, 2]));
